from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from contextlib import asynccontextmanager
from app.routers import auth, users_mgr, accounts_mgr, icon_file_mgr
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

@asynccontextmanager
async def on_startup(app: FastAPI):
    from app.db.db import init_db

    # Initialize the database with default data
    init_db()
    logger.info("Database initialized with default data.")
    yield


app = FastAPI(lifespan=on_startup)
app.mount("/static", StaticFiles(directory="static"), name="static")

app.include_router(auth.router)
app.include_router(users_mgr.router)
app.include_router(accounts_mgr.router)
app.include_router(icon_file_mgr.router)
